// compile: g++ -o heap heap.cc -std=c++11
// run: ./heap
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

void Print(vector<int>& v) {
  for (const auto& t : v) {
    cout << t << " ";
  }
  cout << endl;
}
void Test1() {
  vector<int> v{1, 2, 6, 3, 4, 90, 4};
  make_heap(v.begin(), v.end());  // 默认算子为std::less
  make_heap(v.begin(), v.end(), std::greater_equal<int>());  // 小顶堆
  Print(v);
  pop_heap(v.begin(), v.end(), std::greater<int>());
  Print(v);
  push_heap(v.begin(), v.end(),
            std::greater<int>());  // 将最后一个元素插入[first,last-1)的堆中
  Print(v);
}
void Test2() {}
int main() {
  Test1();
  Test2();
  return 0;
}
